﻿using System;
using System.Web.Mvc;
using System.Web.Mvc.Html;
using CID.Web.Models.Infrastructure;

namespace CID.Web.Support.TemplateContentEdition
{
    public class PartialViewUserInterfaceDefinition : IUserInterfaceDefinition
    {
        public static string TemplateContentEditionViewsBasePath { get; set; }

        public PartialViewUserInterfaceDefinition(string viewName)
        {
            ViewName = viewName;
        }

        public string ViewName { get; private set; }

        public string ViewFullPath
        {
            get
            {
                return String.Format("{0}{1}.cshtml", TemplateContentEditionViewsBasePath, ViewName);
            }
        }

        public MvcHtmlString Apply(HtmlHelper<TemplateViewModel> html)
        {
            return html.Partial(ViewFullPath, html.ViewData.Model);
        }
    }
}